-
Notifications
You must be signed in to change notification settings - Fork 13
Added ability for an inner folder name of a zip to be specified. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Added ability for an inner folder name of a zip to be specified. #17
Conversation
| //Had to do the below, since otherwise the file did not zip in enough time. | ||
| function customZippingFunction(options, customFilePath) { | ||
| return new Promise((resolve, reject) => { | ||
| zipDir( | ||
| customFilePath || sampleZipPath, | ||
| options, | ||
| async function (err, buffer) { | ||
| if (err) { | ||
| reject(err); | ||
| return; | ||
| } | ||
| await fs | ||
| .createReadStream(xpiPath) | ||
| .pipe(unzip.Extract({ path: outputPath })) | ||
| .on("entry", (entry) => entry.autodrain()) | ||
| .promise() | ||
| .then(() => resolve()) | ||
| .catch(e=>reject(e)); | ||
| } | ||
| ); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to wrap the zipping command into its own promise since it was being flaky when running tests, since the zipping often took way too long, and zipDir cannot directly be awaited.
| function customCompareMethod(file, customFilePath = "", combineCustomFilePathOrReplace = true) { | ||
| const zipBuffer = fs.readFileSync(path.join(sampleZipPath, file)); | ||
| const combinedFilePath = path.join(customFilePath, file); | ||
| // Compare the different file buffers. | ||
| const fileBuffer = fs.readFileSync( | ||
| path.join( | ||
| outputPath, | ||
| combineCustomFilePathOrReplace ? combinedFilePath : customFilePath | ||
| ) | ||
| ); | ||
|
|
||
| expect(bufferEqual(zipBuffer, fileBuffer)).to.be.ok; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can move the this function to the global def, but thought i would ask before changing the other aspects. :)
Allows you to define the name of the inner folder of the zip generated. A relevant issue can be found HERE.